package com.iss.okair.db.mapper.sql;

import com.iss.okair.db.entity.Employee;
import org.apache.ibatis.jdbc.SQL;

public class EmployeeSQL {
    public String findEmployee(Employee emp){
        return new SQL(){
            {
                SELECT("e.id,e.empno,e.namecn,e.dept,CONCAT (b.empNo,' ',b.namecn) AS reporttoname");
                FROM("employee  e LEFT JOIN employee b On (b.id = e.reportTo)");

                if (emp.getNamecn()!=null){
                    WHERE("e.namecn like '%"+emp.getNamecn()+"%'");
                }
                if(!"-1".equals(emp.getDept())){
                    WHERE("e.dept=#{dept}");
            }
            }
        }.toString();
    }
}
